<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class RBS::DefinitionBuilder - rbs: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-build_instance">#build_instance</a>
    <li ><a href="#method-i-build_interface">#build_interface</a>
    <li ><a href="#method-i-build_singleton">#build_singleton</a>
    <li ><a href="#method-i-build_singleton0">#build_singleton0</a>
    <li ><a href="#method-i-define_instance">#define_instance</a>
    <li ><a href="#method-i-define_interface">#define_interface</a>
    <li ><a href="#method-i-define_method">#define_method</a>
    <li ><a href="#method-i-ensure_namespace-21">#ensure_namespace!</a>
    <li ><a href="#method-i-expand_alias">#expand_alias</a>
    <li ><a href="#method-i-expand_alias1">#expand_alias1</a>
    <li ><a href="#method-i-expand_alias2">#expand_alias2</a>
    <li ><a href="#method-i-import_methods">#import_methods</a>
    <li ><a href="#method-i-insert_variable">#insert_variable</a>
    <li ><a href="#method-i-interface_methods">#interface_methods</a>
    <li ><a href="#method-i-source_location">#source_location</a>
    <li ><a href="#method-i-tapp_subst">#tapp_subst</a>
    <li ><a href="#method-i-try_cache">#try_cache</a>
    <li ><a href="#method-i-update">#update</a>
    <li ><a href="#method-i-validate_params_with">#validate_params_with</a>
    <li ><a href="#method-i-validate_type_name">#validate_type_name</a>
    <li ><a href="#method-i-validate_type_params">#validate_type_params</a>
    <li ><a href="#method-i-validate_type_presence">#validate_type_presence</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-RBS::DefinitionBuilder">
    <h1 id="class-RBS::DefinitionBuilder" class="class">
      class RBS::DefinitionBuilder
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">



        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-ancestor_builder" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">ancestor_builder</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-env" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">env</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-instance_cache" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">instance_cache</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-interface_cache" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">interface_cache</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-method_builder" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">method_builder</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-singleton0_cache" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">singleton0_cache</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
          <div id="attribute-i-singleton_cache" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">singleton_cache</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(env:, ancestor_builder: nil, method_builder: nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 14</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-value">env:</span>, <span class="ruby-value">ancestor_builder:</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">method_builder:</span> <span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">env</span>
  <span class="ruby-ivar">@ancestor_builder</span> = <span class="ruby-identifier">ancestor_builder</span> <span class="ruby-operator">||</span> <span class="ruby-constant">AncestorBuilder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>)
  <span class="ruby-ivar">@method_builder</span> = <span class="ruby-identifier">method_builder</span> <span class="ruby-operator">||</span> <span class="ruby-constant">MethodBuilder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>)

  <span class="ruby-ivar">@instance_cache</span> = {}
  <span class="ruby-ivar">@singleton_cache</span> = {}
  <span class="ruby-ivar">@singleton0_cache</span> = {}
  <span class="ruby-ivar">@interface_cache</span> = {}
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-build_instance" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_instance</span><span
                                class="method-args">(type_name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="build_instance-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 155</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_instance</span>(<span class="ruby-identifier">type_name</span>)
  <span class="ruby-identifier">type_name</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">normalize_module_name</span>(<span class="ruby-identifier">type_name</span>)

  <span class="ruby-identifier">try_cache</span>(<span class="ruby-identifier">type_name</span>, <span class="ruby-value">cache:</span> <span class="ruby-identifier">instance_cache</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">class_decls</span>[<span class="ruby-identifier">type_name</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown name for build_instance: #{type_name}&quot;</span>
    <span class="ruby-identifier">ensure_namespace!</span>(<span class="ruby-identifier">type_name</span>.<span class="ruby-identifier">namespace</span>, <span class="ruby-value">location:</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decls</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">location</span>)

    <span class="ruby-identifier">ancestors</span> = <span class="ruby-identifier">ancestor_builder</span>.<span class="ruby-identifier">instance_ancestors</span>(<span class="ruby-identifier">type_name</span>)
    <span class="ruby-identifier">args</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">type_params</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">param</span><span class="ruby-operator">|</span> <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Variable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">name:</span> <span class="ruby-identifier">param</span>.<span class="ruby-identifier">name</span>, <span class="ruby-value">location:</span> <span class="ruby-identifier">param</span>.<span class="ruby-identifier">location</span>) }
    <span class="ruby-identifier">self_type</span> = <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassInstance</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">name:</span> <span class="ruby-identifier">type_name</span>, <span class="ruby-value">args:</span> <span class="ruby-identifier">args</span>, <span class="ruby-value">location:</span> <span class="ruby-keyword">nil</span>)

    <span class="ruby-constant">Definition</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">type_name:</span> <span class="ruby-identifier">type_name</span>, <span class="ruby-value">entry:</span> <span class="ruby-identifier">entry</span>, <span class="ruby-value">self_type:</span> <span class="ruby-identifier">self_type</span>, <span class="ruby-value">ancestors:</span> <span class="ruby-identifier">ancestors</span>).<span class="ruby-identifier">tap</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">definition</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">one_ancestors</span> = <span class="ruby-identifier">ancestor_builder</span>.<span class="ruby-identifier">one_instance_ancestors</span>(<span class="ruby-identifier">type_name</span>)
      <span class="ruby-identifier">methods</span> = <span class="ruby-identifier">method_builder</span>.<span class="ruby-identifier">build_instance</span>(<span class="ruby-identifier">type_name</span>)

      <span class="ruby-identifier">validate_type_params</span> <span class="ruby-identifier">definition</span>, <span class="ruby-value">methods:</span> <span class="ruby-identifier">methods</span>, <span class="ruby-value">ancestors:</span> <span class="ruby-identifier">one_ancestors</span>

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassEntry</span>)
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">super_class</span> = <span class="ruby-identifier">one_ancestors</span>.<span class="ruby-identifier">super_class</span>
          <span class="ruby-identifier">super_class</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Ancestor</span><span class="ruby-operator">::</span><span class="ruby-constant">Instance</span>) <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span>

          <span class="ruby-identifier">build_instance</span>(<span class="ruby-identifier">super_class</span>.<span class="ruby-identifier">name</span>).<span class="ruby-identifier">tap</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">defn</span><span class="ruby-operator">|</span>
            <span class="ruby-keyword">unless</span> <span class="ruby-identifier">super_class</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
              <span class="ruby-identifier">super_class</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
                <span class="ruby-identifier">validate_type_presence</span>(<span class="ruby-identifier">arg</span>)
              <span class="ruby-keyword">end</span>

              <span class="ruby-identifier">subst</span> = <span class="ruby-identifier">tapp_subst</span>(<span class="ruby-identifier">super_class</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">super_class</span>.<span class="ruby-identifier">args</span>)
              <span class="ruby-identifier">defn</span> = <span class="ruby-identifier">defn</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-identifier">subst</span>)
            <span class="ruby-keyword">end</span>

            <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">defn</span>.<span class="ruby-identifier">methods</span>)
            <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">instance_variables</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">defn</span>.<span class="ruby-identifier">instance_variables</span>)
            <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">class_variables</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">defn</span>.<span class="ruby-identifier">class_variables</span>)
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ModuleEntry</span>)
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">self_types</span> = <span class="ruby-identifier">one_ancestors</span>.<span class="ruby-identifier">self_types</span>
          <span class="ruby-identifier">self_types</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ans</span><span class="ruby-operator">|</span>
            <span class="ruby-identifier">ans</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
              <span class="ruby-identifier">validate_type_presence</span>(<span class="ruby-identifier">arg</span>)
            <span class="ruby-keyword">end</span>

            <span class="ruby-identifier">subst</span> = <span class="ruby-identifier">tapp_subst</span>(<span class="ruby-identifier">ans</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">ans</span>.<span class="ruby-identifier">args</span>)
            <span class="ruby-keyword">if</span> <span class="ruby-identifier">ans</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">interface?</span>
              <span class="ruby-identifier">define_interface</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">ans</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">subst</span>)
            <span class="ruby-keyword">else</span>
              <span class="ruby-identifier">define_instance</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">ans</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">subst</span>)
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">define_instance</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">type_name</span>, <span class="ruby-constant">Substitution</span>.<span class="ruby-identifier">new</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-build_interface" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_interface</span><span
                                class="method-args">(type_name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="build_interface-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 43</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_interface</span>(<span class="ruby-identifier">type_name</span>)
  <span class="ruby-identifier">try_cache</span>(<span class="ruby-identifier">type_name</span>, <span class="ruby-value">cache:</span> <span class="ruby-identifier">interface_cache</span>) <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">interface_decls</span>[<span class="ruby-identifier">type_name</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown name for build_interface: #{type_name}&quot;</span>
    <span class="ruby-identifier">declaration</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decl</span>
    <span class="ruby-identifier">ensure_namespace!</span>(<span class="ruby-identifier">type_name</span>.<span class="ruby-identifier">namespace</span>, <span class="ruby-value">location:</span> <span class="ruby-identifier">declaration</span>.<span class="ruby-identifier">location</span>)

    <span class="ruby-identifier">type_params</span> = <span class="ruby-identifier">declaration</span>.<span class="ruby-identifier">type_params</span>.<span class="ruby-identifier">each</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>)
    <span class="ruby-identifier">type_args</span> = <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Variable</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">type_params</span>)
    <span class="ruby-identifier">self_type</span> = <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Interface</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">name:</span> <span class="ruby-identifier">type_name</span>, <span class="ruby-value">args:</span> <span class="ruby-identifier">type_args</span>, <span class="ruby-value">location:</span> <span class="ruby-keyword">nil</span>)

    <span class="ruby-identifier">subst</span> = <span class="ruby-constant">Substitution</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">type_params</span>, <span class="ruby-identifier">type_args</span>)

    <span class="ruby-identifier">ancestors</span> = <span class="ruby-identifier">ancestor_builder</span>.<span class="ruby-identifier">interface_ancestors</span>(<span class="ruby-identifier">type_name</span>)
    <span class="ruby-constant">Definition</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">type_name:</span> <span class="ruby-identifier">type_name</span>, <span class="ruby-value">entry:</span> <span class="ruby-identifier">entry</span>, <span class="ruby-value">self_type:</span> <span class="ruby-identifier">self_type</span>, <span class="ruby-value">ancestors:</span> <span class="ruby-identifier">ancestors</span>).<span class="ruby-identifier">tap</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">definition</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">methods</span> = <span class="ruby-identifier">method_builder</span>.<span class="ruby-identifier">build_interface</span>(<span class="ruby-identifier">type_name</span>)
      <span class="ruby-identifier">one_ancestors</span> = <span class="ruby-identifier">ancestor_builder</span>.<span class="ruby-identifier">one_interface_ancestors</span>(<span class="ruby-identifier">type_name</span>)
      <span class="ruby-identifier">validate_type_params</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-value">methods:</span> <span class="ruby-identifier">methods</span>, <span class="ruby-value">ancestors:</span> <span class="ruby-identifier">one_ancestors</span>)

      <span class="ruby-identifier">define_interface</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">subst</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-build_singleton" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_singleton</span><span
                                class="method-args">(type_name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="build_singleton-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 288</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_singleton</span>(<span class="ruby-identifier">type_name</span>)
  <span class="ruby-identifier">type_name</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">normalize_module_name</span>(<span class="ruby-identifier">type_name</span>)

  <span class="ruby-identifier">try_cache</span> <span class="ruby-identifier">type_name</span>, <span class="ruby-value">cache:</span> <span class="ruby-identifier">singleton_cache</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">class_decls</span>[<span class="ruby-identifier">type_name</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown name for build_singleton: #{type_name}&quot;</span>
    <span class="ruby-identifier">ensure_namespace!</span>(<span class="ruby-identifier">type_name</span>.<span class="ruby-identifier">namespace</span>, <span class="ruby-value">location:</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decls</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">location</span>)

    <span class="ruby-identifier">ancestors</span> = <span class="ruby-identifier">ancestor_builder</span>.<span class="ruby-identifier">singleton_ancestors</span>(<span class="ruby-identifier">type_name</span>)
    <span class="ruby-identifier">self_type</span> = <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassSingleton</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">name:</span> <span class="ruby-identifier">type_name</span>, <span class="ruby-value">location:</span> <span class="ruby-keyword">nil</span>)

    <span class="ruby-constant">Definition</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">type_name:</span> <span class="ruby-identifier">type_name</span>, <span class="ruby-value">entry:</span> <span class="ruby-identifier">entry</span>, <span class="ruby-value">self_type:</span> <span class="ruby-identifier">self_type</span>, <span class="ruby-value">ancestors:</span> <span class="ruby-identifier">ancestors</span>).<span class="ruby-identifier">tap</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">definition</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">definition0</span> = <span class="ruby-identifier">build_singleton0</span>(<span class="ruby-identifier">type_name</span>)
      <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">definition0</span>.<span class="ruby-identifier">methods</span>)
      <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">instance_variables</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">definition0</span>.<span class="ruby-identifier">instance_variables</span>)
      <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">class_variables</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">definition0</span>.<span class="ruby-identifier">class_variables</span>)

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassEntry</span>)
        <span class="ruby-identifier">new_method</span> = <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>[<span class="ruby-value">:new</span>]

        <span class="ruby-keyword">if</span> <span class="ruby-identifier">new_method</span>.<span class="ruby-identifier">defs</span>.<span class="ruby-identifier">all?</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">defined_in</span> <span class="ruby-operator">==</span> <span class="ruby-constant">BuiltinNames</span><span class="ruby-operator">::</span><span class="ruby-constant">Class</span>.<span class="ruby-identifier">name</span> }
          <span class="ruby-comment"># The method is _untyped new_.</span>

          <span class="ruby-identifier">alias_methods</span> = <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">each</span>.<span class="ruby-identifier">with_object</span>([]) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span>, <span class="ruby-identifier">array</span><span class="ruby-operator">|</span>
            <span class="ruby-comment"># @type var method: Definition::Method?</span>
            <span class="ruby-identifier">name</span>, <span class="ruby-identifier">method</span> = <span class="ruby-identifier">entry</span>
            <span class="ruby-keyword">while</span> <span class="ruby-identifier">method</span>
              <span class="ruby-keyword">if</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">alias_of</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">new_method</span>
                <span class="ruby-identifier">array</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">name</span>
                <span class="ruby-keyword">break</span>
              <span class="ruby-keyword">end</span>
              <span class="ruby-identifier">method</span> = <span class="ruby-identifier">method</span>.<span class="ruby-identifier">alias_of</span>
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">end</span>

          <span class="ruby-identifier">instance</span> = <span class="ruby-identifier">build_instance</span>(<span class="ruby-identifier">type_name</span>)
          <span class="ruby-identifier">initialize</span> = <span class="ruby-identifier">instance</span>.<span class="ruby-identifier">methods</span>[<span class="ruby-value">:initialize</span>]

          <span class="ruby-keyword">if</span> <span class="ruby-identifier">initialize</span>
            <span class="ruby-identifier">class_params</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">type_params</span>

            <span class="ruby-comment"># Inject a virtual _typed new_.</span>
            <span class="ruby-identifier">initialize_defs</span> = <span class="ruby-identifier">initialize</span>.<span class="ruby-identifier">defs</span>
            <span class="ruby-identifier">typed_new</span> = <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Method</span>.<span class="ruby-identifier">new</span>(
              <span class="ruby-value">super_method:</span> <span class="ruby-identifier">new_method</span>,
              <span class="ruby-value">defs:</span> <span class="ruby-identifier">initialize_defs</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">initialize_def</span><span class="ruby-operator">|</span>
                <span class="ruby-identifier">method_type</span> = <span class="ruby-identifier">initialize_def</span>.<span class="ruby-identifier">type</span>

                <span class="ruby-identifier">class_type_param_vars</span> = <span class="ruby-constant">Set</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">class_params</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>))
                <span class="ruby-identifier">method_type_param_vars</span> = <span class="ruby-constant">Set</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">method_type</span>.<span class="ruby-identifier">type_params</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>))

                <span class="ruby-keyword">if</span> <span class="ruby-identifier">class_type_param_vars</span>.<span class="ruby-identifier">intersect?</span>(<span class="ruby-identifier">method_type_param_vars</span>)
                  <span class="ruby-identifier">new_method_param_names</span> = <span class="ruby-identifier">method_type</span>.<span class="ruby-identifier">type_params</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">method_param</span><span class="ruby-operator">|</span>
                    <span class="ruby-keyword">if</span> <span class="ruby-identifier">class_type_param_vars</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">method_param</span>.<span class="ruby-identifier">name</span>)
                      <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Variable</span>.<span class="ruby-identifier">fresh</span>(<span class="ruby-identifier">method_param</span>.<span class="ruby-identifier">name</span>).<span class="ruby-identifier">name</span>
                    <span class="ruby-keyword">else</span>
                      <span class="ruby-identifier">method_param</span>.<span class="ruby-identifier">name</span>
                    <span class="ruby-keyword">end</span>
                  <span class="ruby-keyword">end</span>

                  <span class="ruby-identifier">sub</span> = <span class="ruby-constant">Substitution</span>.<span class="ruby-identifier">build</span>(
                    <span class="ruby-identifier">method_type</span>.<span class="ruby-identifier">type_params</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>),
                    <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Variable</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">new_method_param_names</span>)
                  )

                  <span class="ruby-identifier">method_params</span> = <span class="ruby-identifier">class_params</span> <span class="ruby-operator">+</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeParam</span>.<span class="ruby-identifier">rename</span>(<span class="ruby-identifier">method_type</span>.<span class="ruby-identifier">type_params</span>, <span class="ruby-value">new_names:</span> <span class="ruby-identifier">new_method_param_names</span>)
                  <span class="ruby-identifier">method_type</span> = <span class="ruby-identifier">method_type</span>
                    .<span class="ruby-identifier">update</span>(<span class="ruby-value">type_params:</span> [])
                    .<span class="ruby-identifier">sub</span>(<span class="ruby-identifier">sub</span>)
                    .<span class="ruby-identifier">update</span>(<span class="ruby-value">type_params:</span> <span class="ruby-identifier">method_params</span>)
                <span class="ruby-keyword">else</span>
                  <span class="ruby-identifier">method_type</span> = <span class="ruby-identifier">method_type</span>
                    .<span class="ruby-identifier">update</span>(<span class="ruby-value">type_params:</span> <span class="ruby-identifier">class_params</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">method_type</span>.<span class="ruby-identifier">type_params</span>)
                <span class="ruby-keyword">end</span>

                <span class="ruby-identifier">method_type</span> = <span class="ruby-identifier">method_type</span>.<span class="ruby-identifier">update</span>(
                  <span class="ruby-value">type:</span> <span class="ruby-identifier">method_type</span>.<span class="ruby-identifier">type</span>.<span class="ruby-identifier">with_return_type</span>(
                    <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassInstance</span>.<span class="ruby-identifier">new</span>(
                      <span class="ruby-value">name:</span> <span class="ruby-identifier">type_name</span>,
                      <span class="ruby-value">args:</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">type_params</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">param</span><span class="ruby-operator">|</span> <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Variable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">name:</span> <span class="ruby-identifier">param</span>.<span class="ruby-identifier">name</span>, <span class="ruby-value">location:</span> <span class="ruby-identifier">param</span>.<span class="ruby-identifier">location</span>) },
                      <span class="ruby-value">location:</span> <span class="ruby-keyword">nil</span>
                    )
                  )
                )

                <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Method</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeDef</span>.<span class="ruby-identifier">new</span>(
                  <span class="ruby-value">type:</span> <span class="ruby-identifier">method_type</span>,
                  <span class="ruby-value">member:</span> <span class="ruby-identifier">initialize_def</span>.<span class="ruby-identifier">member</span>,
                  <span class="ruby-value">defined_in:</span> <span class="ruby-identifier">initialize_def</span>.<span class="ruby-identifier">defined_in</span>,
                  <span class="ruby-value">implemented_in:</span> <span class="ruby-identifier">initialize_def</span>.<span class="ruby-identifier">implemented_in</span>
                )
              <span class="ruby-keyword">end</span>,
              <span class="ruby-value">accessibility:</span> <span class="ruby-value">:public</span>,
              <span class="ruby-value">alias_of:</span> <span class="ruby-keyword">nil</span>
            )

            <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>[<span class="ruby-value">:new</span>] = <span class="ruby-identifier">typed_new</span>

            <span class="ruby-identifier">alias_methods</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">alias_name</span><span class="ruby-operator">|</span>
              <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>[<span class="ruby-identifier">alias_name</span>] = <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>[<span class="ruby-identifier">alias_name</span>].<span class="ruby-identifier">update</span>(
                <span class="ruby-value">alias_of:</span> <span class="ruby-identifier">typed_new</span>,
                <span class="ruby-value">defs:</span> <span class="ruby-identifier">typed_new</span>.<span class="ruby-identifier">defs</span>
              )
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-build_singleton0" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_singleton0</span><span
                                class="method-args">(type_name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Builds a definition for singleton without .new method.</p>

                              <div class="method-source-code" id="build_singleton0-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 217</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_singleton0</span>(<span class="ruby-identifier">type_name</span>)
  <span class="ruby-identifier">try_cache</span> <span class="ruby-identifier">type_name</span>, <span class="ruby-value">cache:</span> <span class="ruby-identifier">singleton0_cache</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">class_decls</span>[<span class="ruby-identifier">type_name</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown name for build_singleton0: #{type_name}&quot;</span>
    <span class="ruby-identifier">ensure_namespace!</span>(<span class="ruby-identifier">type_name</span>.<span class="ruby-identifier">namespace</span>, <span class="ruby-value">location:</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decls</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">location</span>)

    <span class="ruby-identifier">ancestors</span> = <span class="ruby-identifier">ancestor_builder</span>.<span class="ruby-identifier">singleton_ancestors</span>(<span class="ruby-identifier">type_name</span>)
    <span class="ruby-identifier">self_type</span> = <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassSingleton</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">name:</span> <span class="ruby-identifier">type_name</span>, <span class="ruby-value">location:</span> <span class="ruby-keyword">nil</span>)

    <span class="ruby-constant">Definition</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">type_name:</span> <span class="ruby-identifier">type_name</span>, <span class="ruby-value">entry:</span> <span class="ruby-identifier">entry</span>, <span class="ruby-value">self_type:</span> <span class="ruby-identifier">self_type</span>, <span class="ruby-value">ancestors:</span> <span class="ruby-identifier">ancestors</span>).<span class="ruby-identifier">tap</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">definition</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">one_ancestors</span> = <span class="ruby-identifier">ancestor_builder</span>.<span class="ruby-identifier">one_singleton_ancestors</span>(<span class="ruby-identifier">type_name</span>)
      <span class="ruby-identifier">methods</span> = <span class="ruby-identifier">method_builder</span>.<span class="ruby-identifier">build_singleton</span>(<span class="ruby-identifier">type_name</span>)

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">super_class</span> = <span class="ruby-identifier">one_ancestors</span>.<span class="ruby-identifier">super_class</span>
        <span class="ruby-keyword">case</span> <span class="ruby-identifier">super_class</span>
        <span class="ruby-keyword">when</span> <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Ancestor</span><span class="ruby-operator">::</span><span class="ruby-constant">Instance</span>
          <span class="ruby-identifier">defn</span> = <span class="ruby-identifier">build_instance</span>(<span class="ruby-identifier">super_class</span>.<span class="ruby-identifier">name</span>)
        <span class="ruby-keyword">when</span> <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Ancestor</span><span class="ruby-operator">::</span><span class="ruby-constant">Singleton</span>
          <span class="ruby-identifier">defn</span> = <span class="ruby-identifier">build_singleton0</span>(<span class="ruby-identifier">super_class</span>.<span class="ruby-identifier">name</span>)
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">defn</span>.<span class="ruby-identifier">methods</span>)
        <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">instance_variables</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">defn</span>.<span class="ruby-identifier">instance_variables</span>)
        <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">class_variables</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">defn</span>.<span class="ruby-identifier">class_variables</span>)
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">one_ancestors</span>.<span class="ruby-identifier">each_extended_module</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mod</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">validate_type_presence</span>(<span class="ruby-identifier">arg</span>)
        <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">subst</span> = <span class="ruby-identifier">tapp_subst</span>(<span class="ruby-identifier">mod</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">args</span>)
        <span class="ruby-identifier">define_instance</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">subst</span>)
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">all_interfaces</span> = <span class="ruby-identifier">one_ancestors</span>.<span class="ruby-identifier">each_extended_interface</span>.<span class="ruby-identifier">flat_map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">interface</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">other_interfaces</span> = <span class="ruby-identifier">ancestor_builder</span>.<span class="ruby-identifier">interface_ancestors</span>(<span class="ruby-identifier">interface</span>.<span class="ruby-identifier">name</span>).<span class="ruby-identifier">ancestors</span> <span class="ruby-comment">#: Array[Definition::Ancestor::Instance]</span>
        <span class="ruby-identifier">other_interfaces</span> = <span class="ruby-identifier">other_interfaces</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ancestor</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ancestor</span>.<span class="ruby-identifier">source</span> }
        [<span class="ruby-identifier">interface</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">other_interfaces</span>]
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">interface_methods</span> = <span class="ruby-identifier">interface_methods</span>(<span class="ruby-identifier">all_interfaces</span>)
      <span class="ruby-identifier">import_methods</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">methods</span>, <span class="ruby-identifier">interface_methods</span>, <span class="ruby-constant">Substitution</span>.<span class="ruby-identifier">new</span>)

      <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">d</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">members</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">member</span><span class="ruby-operator">|</span>
          <span class="ruby-keyword">case</span> <span class="ruby-identifier">member</span>
          <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrReader</span>, <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrAccessor</span>, <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrWriter</span>
            <span class="ruby-keyword">if</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">kind</span> <span class="ruby-operator">==</span> <span class="ruby-value">:singleton</span>
              <span class="ruby-identifier">ivar_name</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">ivar_name</span>
                          <span class="ruby-keyword">when</span> <span class="ruby-keyword">false</span>
                            <span class="ruby-keyword">nil</span>
                          <span class="ruby-keyword">else</span>
                            <span class="ruby-identifier">member</span>.<span class="ruby-identifier">ivar_name</span> <span class="ruby-operator">||</span> <span class="ruby-value">:&quot;@#{member.name}&quot;</span>
                          <span class="ruby-keyword">end</span>

              <span class="ruby-keyword">if</span> <span class="ruby-identifier">ivar_name</span>
                <span class="ruby-identifier">insert_variable</span>(<span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">instance_variables</span>, <span class="ruby-value">name:</span> <span class="ruby-identifier">ivar_name</span>, <span class="ruby-value">type:</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">type</span>)
              <span class="ruby-keyword">end</span>
            <span class="ruby-keyword">end</span>

          <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassInstanceVariable</span>
            <span class="ruby-identifier">insert_variable</span>(<span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">instance_variables</span>, <span class="ruby-value">name:</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">name</span>, <span class="ruby-value">type:</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">type</span>)

          <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassVariable</span>
            <span class="ruby-identifier">insert_variable</span>(<span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">class_variables</span>, <span class="ruby-value">name:</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">name</span>, <span class="ruby-value">type:</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">type</span>)
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-define_instance" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">define_instance</span><span
                                class="method-args">(definition, type_name, subst)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="define_instance-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 85</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">define_instance</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">subst</span>)
  <span class="ruby-identifier">one_ancestors</span> = <span class="ruby-identifier">ancestor_builder</span>.<span class="ruby-identifier">one_instance_ancestors</span>(<span class="ruby-identifier">type_name</span>)
  <span class="ruby-identifier">methods</span> = <span class="ruby-identifier">method_builder</span>.<span class="ruby-identifier">build_instance</span>(<span class="ruby-identifier">type_name</span>)

  <span class="ruby-identifier">one_ancestors</span>.<span class="ruby-identifier">each_included_module</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mod</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">validate_type_presence</span>(<span class="ruby-identifier">arg</span>)
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">define_instance</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">subst</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">tapp_subst</span>(<span class="ruby-identifier">mod</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">args</span>))
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">all_interfaces</span> = <span class="ruby-identifier">one_ancestors</span>.<span class="ruby-identifier">each_included_interface</span>.<span class="ruby-identifier">flat_map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">interface</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">other_interfaces</span> = <span class="ruby-identifier">ancestor_builder</span>.<span class="ruby-identifier">interface_ancestors</span>(<span class="ruby-identifier">interface</span>.<span class="ruby-identifier">name</span>).<span class="ruby-identifier">ancestors</span> <span class="ruby-comment">#: Array[Definition::Ancestor::Instance]</span>
    <span class="ruby-identifier">other_interfaces</span> = <span class="ruby-identifier">other_interfaces</span>.<span class="ruby-identifier">select</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ancestor</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ancestor</span>.<span class="ruby-identifier">source</span> }
    [<span class="ruby-identifier">interface</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">other_interfaces</span>]
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">interface_methods</span> = <span class="ruby-identifier">interface_methods</span>(<span class="ruby-identifier">all_interfaces</span>)
  <span class="ruby-identifier">import_methods</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">methods</span>, <span class="ruby-identifier">interface_methods</span>, <span class="ruby-identifier">subst</span>)

  <span class="ruby-identifier">one_ancestors</span>.<span class="ruby-identifier">each_prepended_module</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mod</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">validate_type_presence</span>(<span class="ruby-identifier">arg</span>)
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">define_instance</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">subst</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">tapp_subst</span>(<span class="ruby-identifier">mod</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">args</span>))
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">class_decls</span>[<span class="ruby-identifier">type_name</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown name for build_instance: #{type_name}&quot;</span>
  <span class="ruby-identifier">args</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">type_params</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">param</span><span class="ruby-operator">|</span> <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Variable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">name:</span> <span class="ruby-identifier">param</span>.<span class="ruby-identifier">name</span>, <span class="ruby-value">location:</span> <span class="ruby-identifier">param</span>.<span class="ruby-identifier">location</span>) }

  <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decls</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">subst_</span> = <span class="ruby-identifier">subst</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Substitution</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">d</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">type_params</span>.<span class="ruby-identifier">each</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>), <span class="ruby-identifier">args</span>)

    <span class="ruby-identifier">d</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">members</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">member</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">case</span> <span class="ruby-identifier">member</span>
      <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrReader</span>, <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrAccessor</span>, <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrWriter</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">kind</span> <span class="ruby-operator">==</span> <span class="ruby-value">:instance</span>
          <span class="ruby-identifier">ivar_name</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">ivar_name</span>
                      <span class="ruby-keyword">when</span> <span class="ruby-keyword">false</span>
                        <span class="ruby-keyword">nil</span>
                      <span class="ruby-keyword">else</span>
                        <span class="ruby-identifier">member</span>.<span class="ruby-identifier">ivar_name</span> <span class="ruby-operator">||</span> <span class="ruby-value">:&quot;@#{member.name}&quot;</span>
                      <span class="ruby-keyword">end</span>

          <span class="ruby-keyword">if</span> <span class="ruby-identifier">ivar_name</span>
            <span class="ruby-identifier">insert_variable</span>(
              <span class="ruby-identifier">type_name</span>,
              <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">instance_variables</span>,
              <span class="ruby-value">name:</span> <span class="ruby-identifier">ivar_name</span>,
              <span class="ruby-value">type:</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">type</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-identifier">subst_</span>)
            )
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>

      <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">InstanceVariable</span>
        <span class="ruby-identifier">insert_variable</span>(
          <span class="ruby-identifier">type_name</span>,
          <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">instance_variables</span>,
          <span class="ruby-value">name:</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">name</span>,
          <span class="ruby-value">type:</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">type</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-identifier">subst_</span>)
        )

      <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassVariable</span>
        <span class="ruby-identifier">insert_variable</span>(<span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">class_variables</span>, <span class="ruby-value">name:</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">name</span>, <span class="ruby-value">type:</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">type</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-define_interface" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">define_interface</span><span
                                class="method-args">(definition, type_name, subst)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="define_interface-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 33</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">define_interface</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">subst</span>)
  <span class="ruby-identifier">included_interfaces</span> = <span class="ruby-identifier">ancestor_builder</span>.<span class="ruby-identifier">interface_ancestors</span>(<span class="ruby-identifier">type_name</span>).<span class="ruby-identifier">ancestors</span> <span class="ruby-comment">#: Array[Definition::Ancestor::Instance]</span>
  <span class="ruby-identifier">included_interfaces</span> = <span class="ruby-identifier">included_interfaces</span>.<span class="ruby-identifier">reject</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ancestor</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ancestor</span>.<span class="ruby-identifier">source</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> }

  <span class="ruby-identifier">interface_methods</span> = <span class="ruby-identifier">interface_methods</span>(<span class="ruby-identifier">included_interfaces</span>)
  <span class="ruby-identifier">methods</span> = <span class="ruby-identifier">method_builder</span>.<span class="ruby-identifier">build_interface</span>(<span class="ruby-identifier">type_name</span>)

  <span class="ruby-identifier">import_methods</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">methods</span>, <span class="ruby-identifier">interface_methods</span>, <span class="ruby-identifier">subst</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-define_method" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">define_method</span><span
                                class="method-args">(methods, definition, method, subst, defined_in:, implemented_in: defined_in)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="define_method-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 590</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">define_method</span>(<span class="ruby-identifier">methods</span>, <span class="ruby-identifier">definition</span>, <span class="ruby-identifier">method</span>, <span class="ruby-identifier">subst</span>, <span class="ruby-value">defined_in:</span>, <span class="ruby-value">implemented_in:</span> <span class="ruby-identifier">defined_in</span>)
  <span class="ruby-identifier">existing_method</span> = <span class="ruby-identifier">methods</span>[<span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>[<span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>]

  <span class="ruby-keyword">case</span> <span class="ruby-identifier">original</span> = <span class="ruby-identifier">method</span>.<span class="ruby-identifier">original</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">Alias</span>
    <span class="ruby-identifier">original_method</span> = <span class="ruby-identifier">methods</span>[<span class="ruby-identifier">original</span>.<span class="ruby-identifier">old_name</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>[<span class="ruby-identifier">original</span>.<span class="ruby-identifier">old_name</span>]

    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">original_method</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">UnknownMethodAliasError</span>.<span class="ruby-identifier">new</span>(
        <span class="ruby-value">type_name:</span> <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">type_name</span>,
        <span class="ruby-value">original_name:</span> <span class="ruby-identifier">original</span>.<span class="ruby-identifier">old_name</span>,
        <span class="ruby-value">aliased_name:</span> <span class="ruby-identifier">original</span>.<span class="ruby-identifier">new_name</span>,
        <span class="ruby-value">location:</span> <span class="ruby-identifier">original</span>.<span class="ruby-identifier">location</span>
      )
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">method_definition</span> = <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Method</span>.<span class="ruby-identifier">new</span>(
      <span class="ruby-value">super_method:</span> <span class="ruby-identifier">existing_method</span>,
      <span class="ruby-value">defs:</span> <span class="ruby-identifier">original_method</span>.<span class="ruby-identifier">defs</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">defn</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">defn</span>.<span class="ruby-identifier">update</span>(<span class="ruby-value">defined_in:</span> <span class="ruby-identifier">defined_in</span>, <span class="ruby-value">implemented_in:</span> <span class="ruby-identifier">implemented_in</span>)
      <span class="ruby-keyword">end</span>,
      <span class="ruby-value">accessibility:</span> <span class="ruby-identifier">original_method</span>.<span class="ruby-identifier">accessibility</span>,
      <span class="ruby-value">alias_of:</span> <span class="ruby-identifier">original_method</span>
    )
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">MethodDefinition</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">duplicated_method</span> = <span class="ruby-identifier">methods</span>[<span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>]
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">DuplicatedMethodDefinitionError</span>.<span class="ruby-identifier">new</span>(
        <span class="ruby-value">type:</span> <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">self_type</span>,
        <span class="ruby-value">method_name:</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>,
        <span class="ruby-value">members:</span> [<span class="ruby-identifier">original</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">duplicated_method</span>.<span class="ruby-identifier">members</span>]
      )
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">defs</span> = <span class="ruby-identifier">original</span>.<span class="ruby-identifier">overloads</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">overload</span><span class="ruby-operator">|</span>
      <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Method</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeDef</span>.<span class="ruby-identifier">new</span>(
        <span class="ruby-value">type:</span> <span class="ruby-identifier">subst</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">overload</span>.<span class="ruby-identifier">method_type</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">overload</span>.<span class="ruby-identifier">method_type</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-identifier">subst</span>),
        <span class="ruby-value">member:</span> <span class="ruby-identifier">original</span>,
        <span class="ruby-value">defined_in:</span> <span class="ruby-identifier">defined_in</span>,
        <span class="ruby-value">implemented_in:</span> <span class="ruby-identifier">implemented_in</span>
      )
    <span class="ruby-keyword">end</span>

    <span class="ruby-comment"># @type var accessibility: RBS::Definition::accessibility</span>
    <span class="ruby-identifier">accessibility</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-value">:initialize</span>
                      <span class="ruby-value">:private</span>
                    <span class="ruby-keyword">else</span>
                      <span class="ruby-identifier">method</span>.<span class="ruby-identifier">accessibility</span>
                    <span class="ruby-keyword">end</span>

    <span class="ruby-comment"># Skip setting up `super_method` if `implemented_in` is `nil`, that means the type doesn&#39;t have implementation.</span>
    <span class="ruby-comment"># This typically happens if the type is an interface.</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">implemented_in</span>
      <span class="ruby-identifier">super_method</span> = <span class="ruby-identifier">existing_method</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">method_definition</span> = <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Method</span>.<span class="ruby-identifier">new</span>(
      <span class="ruby-value">super_method:</span> <span class="ruby-identifier">super_method</span>,
      <span class="ruby-value">defs:</span> <span class="ruby-identifier">defs</span>,
      <span class="ruby-value">accessibility:</span> <span class="ruby-identifier">accessibility</span>,
      <span class="ruby-value">alias_of:</span> <span class="ruby-keyword">nil</span>
    )
  <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrReader</span>, <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrWriter</span>, <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrAccessor</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">duplicated_method</span> = <span class="ruby-identifier">methods</span>[<span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>]
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">DuplicatedMethodDefinitionError</span>.<span class="ruby-identifier">new</span>(
        <span class="ruby-value">type:</span> <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">self_type</span>,
        <span class="ruby-value">method_name:</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>,
        <span class="ruby-value">members:</span> [<span class="ruby-operator">*</span><span class="ruby-identifier">duplicated_method</span>.<span class="ruby-identifier">members</span>, <span class="ruby-identifier">original</span>]
      )
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">attr_type</span> = <span class="ruby-identifier">original</span>.<span class="ruby-identifier">type</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-identifier">subst</span>)
    <span class="ruby-identifier">method_type</span> =
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">end_with?</span>(<span class="ruby-string">&quot;=&quot;</span>)
        <span class="ruby-comment"># setter</span>
        <span class="ruby-constant">MethodType</span>.<span class="ruby-identifier">new</span>(
          <span class="ruby-value">type_params:</span> [],
          <span class="ruby-value">type:</span> <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Function</span>.<span class="ruby-identifier">empty</span>(<span class="ruby-identifier">attr_type</span>).<span class="ruby-identifier">update</span>(
            <span class="ruby-value">required_positionals:</span> [
              <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Function</span><span class="ruby-operator">::</span><span class="ruby-constant">Param</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">type:</span> <span class="ruby-identifier">attr_type</span>, <span class="ruby-value">name:</span> <span class="ruby-identifier">original</span>.<span class="ruby-identifier">name</span>)
            ]
          ),
          <span class="ruby-value">block:</span> <span class="ruby-keyword">nil</span>,
          <span class="ruby-value">location:</span> <span class="ruby-keyword">nil</span>
        )
      <span class="ruby-keyword">else</span>
        <span class="ruby-comment"># getter</span>
        <span class="ruby-constant">MethodType</span>.<span class="ruby-identifier">new</span>(
          <span class="ruby-value">type_params:</span> [],
          <span class="ruby-value">type:</span> <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Function</span>.<span class="ruby-identifier">empty</span>(<span class="ruby-identifier">attr_type</span>),
          <span class="ruby-value">block:</span> <span class="ruby-keyword">nil</span>,
          <span class="ruby-value">location:</span> <span class="ruby-keyword">nil</span>
        )
      <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">implemented_in</span>
      <span class="ruby-identifier">super_method</span> = <span class="ruby-identifier">existing_method</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">method_definition</span> = <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Method</span>.<span class="ruby-identifier">new</span>(
      <span class="ruby-value">super_method:</span> <span class="ruby-identifier">super_method</span>,
      <span class="ruby-value">defs:</span> [
        <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Method</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeDef</span>.<span class="ruby-identifier">new</span>(
          <span class="ruby-value">type:</span> <span class="ruby-identifier">method_type</span>,
          <span class="ruby-value">member:</span> <span class="ruby-identifier">original</span>,
          <span class="ruby-value">defined_in:</span> <span class="ruby-identifier">defined_in</span>,
          <span class="ruby-value">implemented_in:</span> <span class="ruby-identifier">implemented_in</span>
        )
      ],
      <span class="ruby-value">accessibility:</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">accessibility</span>,
      <span class="ruby-value">alias_of:</span> <span class="ruby-keyword">nil</span>
    )
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>
    <span class="ruby-comment"># Overloading method definition only</span>

    <span class="ruby-keyword">case</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">methods</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>)
      <span class="ruby-comment"># The method is defined in an interface</span>
      <span class="ruby-identifier">super_method</span> = <span class="ruby-identifier">methods</span>[<span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>].<span class="ruby-identifier">super_method</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>)
      <span class="ruby-comment"># The method is defined in the super class</span>
      <span class="ruby-identifier">super_method</span> = <span class="ruby-identifier">existing_method</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-comment"># Cannot find any non-overloading method</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidOverloadMethodError</span>.<span class="ruby-identifier">new</span>(
        <span class="ruby-value">type_name:</span> <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">type_name</span>,
        <span class="ruby-value">method_name:</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>,
        <span class="ruby-value">kind:</span> <span class="ruby-value">:instance</span>,
        <span class="ruby-value">members:</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">overloads</span>
      )
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">method_definition</span> = <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Method</span>.<span class="ruby-identifier">new</span>(
      <span class="ruby-value">super_method:</span> <span class="ruby-identifier">super_method</span>,
      <span class="ruby-value">defs:</span> <span class="ruby-identifier">existing_method</span>.<span class="ruby-identifier">defs</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">defn</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">defn</span>.<span class="ruby-identifier">update</span>(<span class="ruby-value">implemented_in:</span> <span class="ruby-identifier">implemented_in</span>)
      <span class="ruby-keyword">end</span>,
      <span class="ruby-value">accessibility:</span> <span class="ruby-identifier">existing_method</span>.<span class="ruby-identifier">accessibility</span>,
      <span class="ruby-value">alias_of:</span> <span class="ruby-identifier">existing_method</span>.<span class="ruby-identifier">alias_of</span>
    )
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">method</span>.<span class="ruby-identifier">overloads</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">overloading_def</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">overloading_def</span>.<span class="ruby-identifier">overloads</span>.<span class="ruby-identifier">reverse_each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">overload</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">type_def</span> = <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Method</span><span class="ruby-operator">::</span><span class="ruby-constant">TypeDef</span>.<span class="ruby-identifier">new</span>(
        <span class="ruby-value">type:</span> <span class="ruby-identifier">subst</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">overload</span>.<span class="ruby-identifier">method_type</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">overload</span>.<span class="ruby-identifier">method_type</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-identifier">subst</span>),
        <span class="ruby-value">member:</span> <span class="ruby-identifier">overloading_def</span>,
        <span class="ruby-value">defined_in:</span> <span class="ruby-identifier">defined_in</span>,
        <span class="ruby-value">implemented_in:</span> <span class="ruby-identifier">implemented_in</span>
      )

      <span class="ruby-identifier">method_definition</span>.<span class="ruby-identifier">defs</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">type_def</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">methods</span>[<span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">method_definition</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-ensure_namespace-21" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">ensure_namespace!</span><span
                                class="method-args">(namespace, location:)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="ensure_namespace-21-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 25</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ensure_namespace!</span>(<span class="ruby-identifier">namespace</span>, <span class="ruby-value">location:</span>)
  <span class="ruby-identifier">namespace</span>.<span class="ruby-identifier">ascend</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ns</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">ns</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-constant">NoTypeFoundError</span>.<span class="ruby-identifier">check!</span>(<span class="ruby-identifier">ns</span>.<span class="ruby-identifier">to_type_name</span>, <span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>, <span class="ruby-value">location:</span> <span class="ruby-identifier">location</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-expand_alias" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">expand_alias</span><span
                                class="method-args">(type_name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="expand_alias-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 751</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">expand_alias</span>(<span class="ruby-identifier">type_name</span>)
  <span class="ruby-identifier">expand_alias2</span>(<span class="ruby-identifier">type_name</span>, [])
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-expand_alias1" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">expand_alias1</span><span
                                class="method-args">(type_name)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="expand_alias1-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 755</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">expand_alias1</span>(<span class="ruby-identifier">type_name</span>)
  <span class="ruby-identifier">type_name</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">normalize_type_name</span>(<span class="ruby-identifier">type_name</span>)
  <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">type_alias_decls</span>[<span class="ruby-identifier">type_name</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown alias name: #{type_name}&quot;</span>
  <span class="ruby-identifier">as</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">type_params</span>.<span class="ruby-identifier">each</span>.<span class="ruby-identifier">map</span> { <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Bases</span><span class="ruby-operator">::</span><span class="ruby-constant">Any</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">location:</span> <span class="ruby-keyword">nil</span>) }
  <span class="ruby-identifier">expand_alias2</span>(<span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">as</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-expand_alias2" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">expand_alias2</span><span
                                class="method-args">(type_name, args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="expand_alias2-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 762</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">expand_alias2</span>(<span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">type_name</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">normalize_type_name</span>(<span class="ruby-identifier">type_name</span>)
  <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">type_alias_decls</span>[<span class="ruby-identifier">type_name</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown alias name: #{type_name}&quot;</span>

  <span class="ruby-identifier">ensure_namespace!</span>(<span class="ruby-identifier">type_name</span>.<span class="ruby-identifier">namespace</span>, <span class="ruby-value">location:</span> <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">location</span>)
  <span class="ruby-identifier">params</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">type_params</span>.<span class="ruby-identifier">each</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>)

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span>
    <span class="ruby-identifier">as</span> = <span class="ruby-node">&quot;[#{args.join(&quot;, &quot;)}]&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">ps</span> = <span class="ruby-node">&quot;[#{params.join(&quot;, &quot;)}]&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">empty?</span>

    <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Invalid type application: type = #{type_name}#{as}, decl = #{type_name}#{ps}&quot;</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">type</span> = <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">type</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">empty?</span>
    <span class="ruby-identifier">subst</span> = <span class="ruby-constant">Substitution</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">args</span>)
    <span class="ruby-identifier">type</span> = <span class="ruby-identifier">type</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-identifier">subst</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">type</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-import_methods" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">import_methods</span><span
                                class="method-args">(definition, module_name, module_methods, interfaces_methods, subst)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="import_methods-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 532</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">import_methods</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-identifier">module_name</span>, <span class="ruby-identifier">module_methods</span>, <span class="ruby-identifier">interfaces_methods</span>, <span class="ruby-identifier">subst</span>)
  <span class="ruby-identifier">new_methods</span> = {} <span class="ruby-comment">#: Hash[Symbol, Definition::Method]</span>
  <span class="ruby-identifier">interface_method_duplicates</span> = <span class="ruby-constant">Set</span>[] <span class="ruby-comment">#: Set[Symbol]</span>

  <span class="ruby-identifier">interfaces_methods</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">interface</span>, (<span class="ruby-identifier">methods</span>, <span class="ruby-identifier">member</span>)<span class="ruby-operator">|</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">interface</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
      <span class="ruby-identifier">methods</span>.<span class="ruby-identifier">type</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Interface</span>) <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span>
      <span class="ruby-identifier">params</span> = <span class="ruby-identifier">methods</span>.<span class="ruby-identifier">type</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Variable</span>) <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span>
        <span class="ruby-identifier">arg</span>.<span class="ruby-identifier">name</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">interface</span>.<span class="ruby-identifier">args</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">arg</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">validate_type_presence</span>(<span class="ruby-identifier">arg</span>)
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">subst_</span> = <span class="ruby-identifier">subst</span> <span class="ruby-operator">+</span> <span class="ruby-constant">Substitution</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">interface</span>.<span class="ruby-identifier">args</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">subst_</span> = <span class="ruby-identifier">subst</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">methods</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">method</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">interface_method_duplicates</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>)
        <span class="ruby-identifier">member</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">Include</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">member</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">Extend</span>) <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span>

        <span class="ruby-identifier">raise</span> <span class="ruby-constant">DuplicatedInterfaceMethodDefinitionError</span>.<span class="ruby-identifier">new</span>(
          <span class="ruby-value">type:</span> <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">self_type</span>,
          <span class="ruby-value">method_name:</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>,
          <span class="ruby-value">member:</span> <span class="ruby-identifier">member</span>
        )
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">interface_method_duplicates</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">method</span>.<span class="ruby-identifier">name</span>
      <span class="ruby-identifier">define_method</span>(
        <span class="ruby-identifier">new_methods</span>,
        <span class="ruby-identifier">definition</span>,
        <span class="ruby-identifier">method</span>,
        <span class="ruby-identifier">subst_</span>,
        <span class="ruby-value">defined_in:</span> <span class="ruby-identifier">interface</span>.<span class="ruby-identifier">name</span>,
        <span class="ruby-value">implemented_in:</span> <span class="ruby-identifier">module_name</span>
      )
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">module_methods</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">method</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">define_method</span>(
      <span class="ruby-identifier">new_methods</span>,
      <span class="ruby-identifier">definition</span>,
      <span class="ruby-identifier">method</span>,
      <span class="ruby-identifier">subst</span>,
      <span class="ruby-value">defined_in:</span> <span class="ruby-identifier">module_name</span>,
      <span class="ruby-value">implemented_in:</span> <span class="ruby-identifier">module_name</span>.<span class="ruby-identifier">interface?</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">module_name</span>
    )
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">methods</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">new_methods</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-insert_variable" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">insert_variable</span><span
                                class="method-args">(type_name, variables, name:, type:)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="insert_variable-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 524</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">insert_variable</span>(<span class="ruby-identifier">type_name</span>, <span class="ruby-identifier">variables</span>, <span class="ruby-value">name:</span>, <span class="ruby-value">type:</span>)
  <span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Variable</span>.<span class="ruby-identifier">new</span>(
    <span class="ruby-value">parent_variable:</span> <span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>],
    <span class="ruby-value">type:</span> <span class="ruby-identifier">type</span>,
    <span class="ruby-value">declared_in:</span> <span class="ruby-identifier">type_name</span>
  )
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-interface_methods" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">interface_methods</span><span
                                class="method-args">(interface_ancestors)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="interface_methods-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 398</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">interface_methods</span>(<span class="ruby-identifier">interface_ancestors</span>)
  <span class="ruby-identifier">interface_methods</span> = {} <span class="ruby-comment">#: interface_methods</span>

  <span class="ruby-identifier">interface_ancestors</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">mod</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">source</span> =
      <span class="ruby-keyword">case</span> <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">source</span>
      <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">Include</span>, <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">Extend</span>
        <span class="ruby-identifier">mod</span>.<span class="ruby-identifier">source</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Interface mixin must be include/extend: #{mod.source.inspect}&quot;</span>
      <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">methods</span> = <span class="ruby-identifier">method_builder</span>.<span class="ruby-identifier">build_interface</span>(<span class="ruby-identifier">mod</span>.<span class="ruby-identifier">name</span>)

    <span class="ruby-identifier">interface_methods</span>[<span class="ruby-identifier">mod</span>] = [<span class="ruby-identifier">methods</span>, <span class="ruby-identifier">source</span>]
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">interface_methods</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-source_location" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">source_location</span><span
                                class="method-args">(source, decl)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="source_location-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 428</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">source_location</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">decl</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">source</span>
  <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>
    <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">location</span>
  <span class="ruby-keyword">when</span> <span class="ruby-value">:super</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">decl</span>
    <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Declarations</span><span class="ruby-operator">::</span><span class="ruby-constant">Class</span>
      <span class="ruby-identifier">decl</span>.<span class="ruby-identifier">super_class</span>&amp;.<span class="ruby-identifier">location</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">source</span>.<span class="ruby-identifier">location</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-tapp_subst" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">tapp_subst</span><span
                                class="method-args">(name, args)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="tapp_subst-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 66</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">tapp_subst</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">params</span> =
    <span class="ruby-keyword">case</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">interface?</span>
      <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">interface_decls</span>[<span class="ruby-identifier">name</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown interface name: #{name}&quot;</span>
      <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">type_params</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">alias?</span>
      <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">type_alias_decls</span>[<span class="ruby-identifier">name</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown alias name: #{name}&quot;</span>
      <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decl</span>.<span class="ruby-identifier">type_params</span>
    <span class="ruby-keyword">when</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">class?</span>
      <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">env</span>.<span class="ruby-identifier">class_decls</span>[<span class="ruby-identifier">name</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unknown module name: #{name}&quot;</span>
      <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">type_params</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">raise</span>
    <span class="ruby-keyword">end</span>

  <span class="ruby-constant">Substitution</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">params</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>), <span class="ruby-identifier">args</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-try_cache" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">try_cache</span><span
                                class="method-args">(type_name, cache:) { || ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="try_cache-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 747</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">try_cache</span>(<span class="ruby-identifier">type_name</span>, <span class="ruby-value">cache:</span>)
  <span class="ruby-identifier">cache</span>[<span class="ruby-identifier">type_name</span>] <span class="ruby-operator">||=</span> <span class="ruby-keyword">yield</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-update" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">update</span><span
                                class="method-args">(env:, except:, ancestor_builder:)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="update-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 786</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">update</span>(<span class="ruby-value">env:</span>, <span class="ruby-value">except:</span>, <span class="ruby-value">ancestor_builder:</span>)
  <span class="ruby-identifier">method_builder</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">method_builder</span>.<span class="ruby-identifier">update</span>(<span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>, <span class="ruby-value">except:</span> <span class="ruby-identifier">except</span>)

  <span class="ruby-constant">DefinitionBuilder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">env:</span> <span class="ruby-identifier">env</span>, <span class="ruby-value">ancestor_builder:</span> <span class="ruby-identifier">ancestor_builder</span>, <span class="ruby-value">method_builder:</span> <span class="ruby-identifier">method_builder</span>).<span class="ruby-identifier">tap</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">builder</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">instance_cache</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">instance_cache</span>)
    <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">singleton_cache</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">singleton_cache</span>)
    <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">singleton0_cache</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">singleton0_cache</span>)
    <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">interface_cache</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">interface_cache</span>)

    <span class="ruby-identifier">except</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">instance_cache</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">name</span>)
      <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">singleton_cache</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">name</span>)
      <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">singleton0_cache</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">name</span>)
      <span class="ruby-identifier">builder</span>.<span class="ruby-identifier">interface_cache</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">name</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-validate_params_with" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">validate_params_with</span><span
                                class="method-args">(type_params, result:) { |param| ... }</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="validate_params_with-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 418</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">validate_params_with</span>(<span class="ruby-identifier">type_params</span>, <span class="ruby-value">result:</span>)
  <span class="ruby-identifier">type_params</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">param</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">param</span>.<span class="ruby-identifier">unchecked?</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">compatible?</span>(<span class="ruby-identifier">param</span>.<span class="ruby-identifier">name</span>, <span class="ruby-value">with_annotation:</span> <span class="ruby-identifier">param</span>.<span class="ruby-identifier">variance</span>)
        <span class="ruby-keyword">yield</span> <span class="ruby-identifier">param</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-validate_type_name" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">validate_type_name</span><span
                                class="method-args">(name, location)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="validate_type_name-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 815</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">validate_type_name</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">location</span>)
  <span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">absolute!</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">absolute?</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">env</span>.<span class="ruby-identifier">type_name?</span>(<span class="ruby-identifier">env</span>.<span class="ruby-identifier">normalize_type_name</span>(<span class="ruby-identifier">name</span>))

  <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoTypeFoundError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">type_name:</span> <span class="ruby-identifier">name</span>, <span class="ruby-value">location:</span> <span class="ruby-identifier">location</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-validate_type_params" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">validate_type_params</span><span
                                class="method-args">(definition, ancestors:, methods:)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="validate_type_params-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 442</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">validate_type_params</span>(<span class="ruby-identifier">definition</span>, <span class="ruby-value">ancestors:</span>, <span class="ruby-value">methods:</span>)
  <span class="ruby-identifier">type_params</span> = <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">type_params_decl</span>

  <span class="ruby-identifier">calculator</span> = <span class="ruby-constant">VarianceCalculator</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">builder:</span> <span class="ruby-keyword">self</span>)
  <span class="ruby-identifier">param_names</span> = <span class="ruby-identifier">type_params</span>.<span class="ruby-identifier">each</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>)

  <span class="ruby-identifier">ancestors</span>.<span class="ruby-identifier">each_ancestor</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ancestor</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">ancestor</span>
    <span class="ruby-keyword">when</span> <span class="ruby-constant">Definition</span><span class="ruby-operator">::</span><span class="ruby-constant">Ancestor</span><span class="ruby-operator">::</span><span class="ruby-constant">Instance</span>
      <span class="ruby-identifier">result</span> = <span class="ruby-identifier">calculator</span>.<span class="ruby-identifier">in_inherit</span>(<span class="ruby-value">name:</span> <span class="ruby-identifier">ancestor</span>.<span class="ruby-identifier">name</span>, <span class="ruby-value">args:</span> <span class="ruby-identifier">ancestor</span>.<span class="ruby-identifier">args</span>, <span class="ruby-value">variables:</span> <span class="ruby-identifier">param_names</span>)
      <span class="ruby-identifier">validate_params_with</span>(<span class="ruby-identifier">type_params</span>, <span class="ruby-value">result:</span> <span class="ruby-identifier">result</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">param</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">decl</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">entry</span> = <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">entry</span>
               <span class="ruby-keyword">when</span> <span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ModuleEntry</span>, <span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassEntry</span>
                 <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">primary</span>.<span class="ruby-identifier">decl</span>
               <span class="ruby-keyword">when</span> <span class="ruby-constant">Environment</span><span class="ruby-operator">::</span><span class="ruby-constant">SingleEntry</span>
                 <span class="ruby-identifier">entry</span>.<span class="ruby-identifier">decl</span>
               <span class="ruby-keyword">end</span>

        <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidVarianceAnnotationError</span>.<span class="ruby-identifier">new</span>(
          <span class="ruby-value">type_name:</span> <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">type_name</span>,
          <span class="ruby-value">param:</span> <span class="ruby-identifier">param</span>,
          <span class="ruby-value">location:</span> <span class="ruby-identifier">source_location</span>(<span class="ruby-identifier">ancestor</span>.<span class="ruby-identifier">source</span>, <span class="ruby-identifier">decl</span>)
        )
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">methods</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">defn</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">defn</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-value">:initialize</span>

    <span class="ruby-identifier">method_types</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">original</span> = <span class="ruby-identifier">defn</span>.<span class="ruby-identifier">original</span>
                   <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">MethodDefinition</span>
                     <span class="ruby-identifier">original</span>.<span class="ruby-identifier">overloads</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:method_type</span>)
                   <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrWriter</span>, <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrReader</span>, <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">AttrAccessor</span>
                     <span class="ruby-keyword">if</span> <span class="ruby-identifier">defn</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">end_with?</span>(<span class="ruby-string">&quot;=&quot;</span>)
                       [
                         <span class="ruby-constant">MethodType</span>.<span class="ruby-identifier">new</span>(
                           <span class="ruby-value">type_params:</span> [],
                           <span class="ruby-value">type:</span> <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Function</span>.<span class="ruby-identifier">empty</span>(<span class="ruby-identifier">original</span>.<span class="ruby-identifier">type</span>).<span class="ruby-identifier">update</span>(
                             <span class="ruby-value">required_positionals:</span> [
                               <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Function</span><span class="ruby-operator">::</span><span class="ruby-constant">Param</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">type:</span> <span class="ruby-identifier">original</span>.<span class="ruby-identifier">type</span>, <span class="ruby-value">name:</span> <span class="ruby-identifier">original</span>.<span class="ruby-identifier">name</span>)
                             ]
                           ),
                           <span class="ruby-value">block:</span> <span class="ruby-keyword">nil</span>,
                           <span class="ruby-value">location:</span> <span class="ruby-identifier">original</span>.<span class="ruby-identifier">location</span>
                         )
                       ]
                     <span class="ruby-keyword">else</span>
                       [
                         <span class="ruby-constant">MethodType</span>.<span class="ruby-identifier">new</span>(
                           <span class="ruby-value">type_params:</span> [],
                           <span class="ruby-value">type:</span> <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Function</span>.<span class="ruby-identifier">empty</span>(<span class="ruby-identifier">original</span>.<span class="ruby-identifier">type</span>),
                           <span class="ruby-value">block:</span> <span class="ruby-keyword">nil</span>,
                           <span class="ruby-value">location:</span> <span class="ruby-identifier">original</span>.<span class="ruby-identifier">location</span>
                         )
                       ]
                     <span class="ruby-keyword">end</span>
                   <span class="ruby-keyword">when</span> <span class="ruby-constant">AST</span><span class="ruby-operator">::</span><span class="ruby-constant">Members</span><span class="ruby-operator">::</span><span class="ruby-constant">Alias</span>
                     <span class="ruby-keyword">nil</span>
                   <span class="ruby-keyword">when</span> <span class="ruby-keyword">nil</span>
                     <span class="ruby-keyword">nil</span>
                   <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">method_types</span>
      <span class="ruby-identifier">method_types</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">method_type</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">merged_params</span> = <span class="ruby-identifier">type_params</span>
          .<span class="ruby-identifier">reject</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">param</span><span class="ruby-operator">|</span> <span class="ruby-identifier">method_type</span>.<span class="ruby-identifier">type_param_names</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">param</span>.<span class="ruby-identifier">name</span>) }
          .<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">method_type</span>.<span class="ruby-identifier">type_params</span>)

        <span class="ruby-identifier">result</span> = <span class="ruby-identifier">calculator</span>.<span class="ruby-identifier">in_method_type</span>(<span class="ruby-value">method_type:</span> <span class="ruby-identifier">method_type</span>, <span class="ruby-value">variables:</span> <span class="ruby-identifier">param_names</span>)
        <span class="ruby-identifier">validate_params_with</span>(<span class="ruby-identifier">merged_params</span>, <span class="ruby-value">result:</span> <span class="ruby-identifier">result</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">param</span><span class="ruby-operator">|</span>
          <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidVarianceAnnotationError</span>.<span class="ruby-identifier">new</span>(
            <span class="ruby-value">type_name:</span> <span class="ruby-identifier">definition</span>.<span class="ruby-identifier">type_name</span>,
            <span class="ruby-value">param:</span> <span class="ruby-identifier">param</span>,
            <span class="ruby-value">location:</span> <span class="ruby-identifier">method_type</span>.<span class="ruby-identifier">location</span>
          )
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-validate_type_presence" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">validate_type_presence</span><span
                                class="method-args">(type)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="validate_type_presence-source">
            <pre><span class="ruby-comment"># File rbs-3.2.1/lib/rbs/definition_builder.rb, line 804</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">validate_type_presence</span>(<span class="ruby-identifier">type</span>)
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
  <span class="ruby-keyword">when</span> <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassInstance</span>, <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassSingleton</span>, <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Interface</span>, <span class="ruby-constant">Types</span><span class="ruby-operator">::</span><span class="ruby-constant">Alias</span>
    <span class="ruby-identifier">validate_type_name</span>(<span class="ruby-identifier">type</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">type</span>.<span class="ruby-identifier">location</span>)
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">type</span>.<span class="ruby-identifier">each_type</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">type</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">validate_type_presence</span>(<span class="ruby-identifier">type</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

